/* 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifndef WISHMASTER_ATTACHMENT_H
#define WISHMASTER_ATTACHMENT_H

#include <QString>
#include <QByteArray>
#include <QImage>
#include <QSharedPointer>
#include <QUrl>
#include "misc.h"

namespace Wishmaster
{
	class Attachment;
	typedef QSharedPointer<Attachment> AttachmentPtr;
	class WISHMASTER_EXPORT Attachment
	{
	public:
		static AttachmentPtr create(const QUrl& thumblink, const QUrl& link, const QByteArray& data = QByteArray());
		virtual ~Attachment();

		void setThumbnail(const QImage& image);
		QImage thumbnail();

		void setThumnailUrl(const QUrl& url);
		QUrl thumbnailUrl();

		void setUrl(const QUrl& url);
		QUrl url();
		QString filename();

		void setData(const QByteArray& data);
		QByteArray data();

		QImage image();

		void setType(const QString& type);
		QString type();

		bool hasThumbnail() const;
		bool hasData() const;

		static const int NoAttachment = -1;
	
	private:
		Attachment(const QUrl& thumblink, const QUrl& link, const QByteArray& data);
		Attachment(const Attachment& /*attachment*/) {}

		QString detectType(const QUrl& link);
		QImage m_thumbnail;
		QByteArray m_data;
		QImage m_image;
		QString m_type;
		QUrl m_url;
		QUrl m_thumbUrl;
	};
}

#endif

